<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <title>任务日志</title>
  <link rel="stylesheet" href="../../../template/assets/css/amazeui.min.css"/>
  <link rel="stylesheet" href="../../../template/website/css/app.css"/>
</head>
<body>
  <table class="am-table am-text-sm">
    <thead>
      <tr>
        <th colspan="2">日志详情</th>
      </tr>
    </thead>
    <tbody>
      <script type="text/x-handlebars-template" id="amz-detail">
      {{#with info}}
        <tr>
          <td class="am-text-nowrap">日志名称</td>
          <td class="am-text-secondary">{{workNoteTitle}}</td>
        </tr>
        <tr>
          <td class="am-text-nowrap">日志编号</td>
          <td class="am-text-secondary">{{workNoteId}}</td>
        </tr>
        <tr>
          <td class="am-text-nowrap">开始时间</td>
          <td class="am-text-secondary">{{actionBeginDate}}</td>
        </tr>
        <tr>
          <td class="am-text-nowrap">结束时间</td>
          <td class="am-text-secondary">{{actionEndDate}}</td>
        </tr>
        <tr>
          <td class="am-text-nowrap">创建人</td>
          <td class="am-text-secondary">{{createrName}}</td>
        </tr>
        <tr>
          <td>创建时间</td>
          <td class="am-text-secondary">{{createDate}}</td>
        </tr>
        <tr>
          <td class="am-text-nowrap">客户经理</td>
          <td class="am-text-secondary">{{custMngrName}}</td>
        </tr>
        <tr>
          <td class="am-text-nowrap">集团编码</td>
          <td class="am-text-secondary">{{entCustCo}}</td>
        </tr>
        <tr>
          <td class="am-text-nowrap">集团名称</td>
          <td class="am-text-secondary">{{entCustName}}</td>
        </tr>
        <tr>
          <td class="am-text-nowrap">任务类型</td>
          <td class="am-text-secondary">{{actionKindText}}</td>
        </tr>
         <tr id="guanhuaiTr" style="display: 'none'">
          <td class="am-text-nowrap">服务关怀事项</td>
          <td class="am-text-secondary">{{guanhuaiType}}</td>
        </tr>
        <tr>
          <td class="am-text-nowrap">工作方式</td>
          <td class="am-text-secondary">{{actionType}}</td>
        </tr>
        <tr>
          <td class="am-text-nowrap">状态</td>
          <td class="am-text-secondary">{{dataState}}</td>
        </tr>
        <tr>
          <td class="am-text-nowrap">日志内容</td>
          <td class="am-text-secondary">{{actionContent}}</td>
        </tr>
        {{/with}}
      </script>
    </tbody>
  </table>
  <div class="am-u-sm-12 am-topbar am-topbar-fixed-bottom am-padding-vertical-xs">
    <div class="am-u-sm-12">
      <button type="button" class="am-btn am-btn-default am-btn-block" onclick="javascript:history.go(-1);">返  回</button>
    </div>
  </div>
  <div class="am-modal am-modal-no-btn" tabindex="-1" id="modal">
    <div class="am-modal-dialog">
      <div class="am-modal-hd">正在载入...</div>
      <div class="am-modal-bd">
        <span class="am-icon-spinner am-icon-spin"></span>
      </div>
    </div>
  </div>
  <script type="text/javascript" src="../../../template/assets/js/jquery.min.js"></script>
  <script type="text/javascript" src="../../../template/assets/js/amazeui.min.js"></script>
  <script type="text/javascript" src="../../../template/assets/js/handlebars.min.js"></script>
  <script type="text/javascript" src="../../../template/assets/js/amazeui.widgets.helper.min.js"></script>
  <script type="text/javascript" src="../../../template/website/js/app.js"></script>
  <script type="text/javascript" src="../../../template/website/js/goventerprise/esop/tasklog_params.js"></script>
  <script type="text/javascript">
    $(function(){
      loadDatas();
    });

    //返回页面分享的参数,当当前页面有canAppShare=1参数时需要添加此函数resShareParm(函数名不能改，客户端已经只调用这个函数)
    function resShareParm() {
        var regText1 = "saleType=1";
        var regText2 = "saleType=3";
        var regS1 = new RegExp(regText1, "gi");
        var regS2 = new RegExp(regText2, "gi");
        var urlpath = window.location.href.replace(regS1, "saleType=2").replace(regS2, "saleType=4");//修改平台类型(原生分享出去统一改为分享平台)：1（直销通代客下单）改为 2（直销通分享页面购买） 3（微店原生购买）改为 4（微店分享购买）
        var imgpath = 'http://'+window.location.host+'/upload/file/default_head_img.png';
        var title = "用移动手机宽带免费送";
        var description = "超人气预约套餐等你来约";
        var data = "url=" + urlpath + "&&img=" + imgpath + "&&title=" + title + "&&description=" + description + "";
        return data;
    }

    /*
    加载数据
    */
    var loadDatas = function() {
      $('#modal').modal('open');
      var empCode = getParamValue("empCode");
      var workNoteId = getParamValue("id");
      var data = JSON.stringify(getDetailJsonParams(getParamValue("token"), empCode, workNoteId));
      console.log("data=" + data);
      $.ajax({
        type: "post",
        contentType: "application/json",
        url: Constants.rpcEsopHost+"queryWorkNoteDetail",
        data: data,
        dataType: "json",
        headers: {
      'token': getParamValue('token'),
      'saleType': getParamValue('saleType')
    },
    success: function(data) {
      if (data.ResultCode === 1009) {
        alert('登陆超时，请重新登录！');
        jumpToSignin();
        return;
      }
          $('#modal').modal('close');
          //$.AMUI.progress.done();
          pageData = data;
          console.info(data);
          showDatas(data);
        },
        error: function(textStatus) {
          //$.AMUI.progress.done();
          $('#modal').modal('close');
          alert("获取系统公告失败！");
          console.info("request error:"+textStatus);
        }
      });
    };

    var showDetail = function(info) {
      var $detail = $('#amz-detail');
      var source = $detail.text();
      var template = Handlebars.compile(source);

      info.entCustCo = checkNil(info.entCustCo);
      info.entCustName = checkNil(info.entCustName);
      info.createrName = checkNil(info.createrName);
      info.workNoteTitle = checkNil(info.workNoteTitle);
      info.actionBeginDate = checkNil(info.actionBeginDate);
      info.actionEndDate = checkNil(info.actionEndDate);
      info.createDate = checkNil(info.createDate);
      info.custMngrName = checkNil(info.custMngrName);
      info.actionContent = checkNil(info.actionContent);

      if(info.actionKind ==3){
        info.guanhuaiType = getGuanhuaiType(info.guanhuaiTypeId);
      }
      info.actionKindText = getActionKind(info.actionKind.trim());
      info.actionType = getActionType(info.actionType);
      info.dataState = getStateType(info.dataState);
      var data = {
        info: info,
        "error": "无公告信息!"
      };
      var html = template(data);
      $detail.before(html);
      if(info.actionKind != 3){
        $("#guanhuaiTr").hide();
      }
    }

    /*
    显示数据
    */
    var showDatas = function(data) {
      var $bulletin_list = $('#amz-list');
      var source = $bulletin_list.text();
      var template = Handlebars.compile(source);    
      var unreadCount = 0;
      var readCount = 0;

      if(data.rtnCode!=1000){
        alert(data.rtnMsg);
        return;
      }
      showDetail(data.return.workNoteInfos);
    };

    function GetQueryString(name)
    {
         var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
         var r = window.location.search.substr(1).match(reg);
         if(r!=null)return  unescape(r[2]); return null;
    }
    
  </script>
</body>
</html>